(function (win, $) {
    var POPUP = {};
    POPUP.Cmd = function (title, area, content) {
        this.title = title;
        this.area = area;
        this.content = content;
        this.btn = ['确定', '取消'];
        this.maxmin = true;
        this.resize = false;
        this.btnAlign = 'c';
        this.shade = 0.2;
    };
    POPUP.Cmd.prototype = {
        setTitle: function (title) {
            this.title = title;
        },
        setArea: function (area) {
            this.area = area;
        },
        setContent: function (content) {
            this.content = content;
        },
        setBtn: function (btn) {
            this.btn = btn;
        },
        setMaxmin: function (maxmin) {
            this.maxmin = maxmin;
        },
        setResize: function (resize) {
            this.resize = resize;
        },
        setBtnAlign: function (btnAlign) {
            this.btnAlign = btnAlign;
        },
        setShade: function (shade) {
            this.shade = shade;
        },
        getBody: function () {
            return this.body;
        },
        getIframeWin: function () {
            return this.iframeWin;
        },
        dialog0: function (callback1, callback2) { // iframe层
            var that = this;
            var bool = true;
            var config = {
                type: 2,
                title: that.title,
                area: that.area,
                maxmin: that.maxmin,
                resize: that.resize,
                btnAlign: that.btnAlign,
                content: that.content,
                btn: that.btn,
                yes: function (index, layero) {
                    that.body = layer.getChildFrame('body', index);
                    that.iframeWin = window[layero.find('iframe')[0]['name']];
                    if (callback1) {
                        bool = callback1();
                    }
                    if (bool) {
                        layer.close(index);
                    }
                },
                btn2: function (index, layero) { // 第二个按钮的操作
                    that.body = layer.getChildFrame('body', index);
                    that.iframeWin = window[layero.find('iframe')[0]['name']];
                    if (callback2) {
                        bool = callback2()
                    }
                    if (bool) {
                        layer.close(index);
                    }
                }
            };
            layer.open(config);
        },
        dialog: function (callback1, callback2) { // 页面层
            var that = this;
            var bool = true;
            var config = {
                type: 1,
                title: that.title,
                area: that.area,
                maxmin: that.maxmin,
                resize: that.resize,
                btnAlign: that.btnAlign,
                content: that.content,
                btn: that.btn,
                yes: function (index, layero) {
                    if (callback1) {
                        bool = callback1();
                    }
                    if (bool) {
                        layer.close(index);
                    }
                },
                btn2: function (index, layero) { // 第二个按钮的操作
                    if (callback2) {
                        bool = callback2()
                    }
                    if (bool) {
                        layer.close(index);
                    }
                }
            };
            layer.open(config);
        }
    };
    win.POPUP = POPUP;
})(window, jQuery);